package com.fanghuyun.iswaf.extention;

import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;

public class Extention {
	
	public void addExtentionJar(String jarPath,String classPath,String method,Object[] obj){
		try {
			URL url = new File(jarPath).toURI().toURL();
			URLClassLoader ucl = new URLClassLoader(new URL[]{url});
			Class<?> c = Class.forName(classPath,true,ucl);
			Object o = c.newInstance();
			Method m = c.getDeclaredMethod(method);
			m.setAccessible(true);
			m.invoke(o, obj);
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (NoSuchMethodException e) {
			e.printStackTrace();
		} catch (SecurityException e) {
			e.printStackTrace();
		} catch (IllegalArgumentException e) {
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		}
	}

}
